<?php
namespace App\Logic\ZiNiao\Work;

use App\Models\Basics\AmazonAccount;
use App\Models\Basics\SysCountry;
use App\Models\Basics\SysPlatAccount;

class Helper
{
    public static function storeAndMarketPlaceList($accountId = 0){
        $where = $accountId ? ['id' => $accountId] : ['api' => 1];
        $query = SysPlatAccount::query()->where(formatCondition($where));
        $res = $query->where('status',1)->get();
        $data = [];
        foreach ($res as $re){
            $countryIds = $re->account_country->pluck('country_id');
            if(!$countryIds)continue;
            $country = SysCountry::query()
                ->whereIn('id',$countryIds)
                ->pluck('country');
            if(!$country)continue;
            $data[] = [
                "sellerIds" => $re->merchant,
                "marketPlace" => implode(',',$country->toArray())
            ];
        }
        return $data;
    }
}
